/**
 *	---------------------------------------------------------------------------
 *	COMP 6231/FALL 2013
 *	Assignment - 02
 *	@author Talha Rahman (1296884)
 *	---------------------------------------------------------------------------
 *	This class loads and contains necessary configuration parameters for the 
 *	RMI client {@link OfficerClient} application.
 *	@see {@link OfficerClient}
 *	  
 */
package ca.concordia.comp6231.client;

import java.util.HashMap;

public class OfficerClientConfiguration {
	private String stationName;
	private HashMap <String, String> serverConnectionString;
	
	/**
	 * Constructor
	 * @param stationName
	 */
	public OfficerClientConfiguration(String stationName){
		this.stationName = stationName;
		setSecurityPolicy();
		loadServerConnectionString();
	}
	
	/**
	 * Sets the Java VM security policy to allow RMI connections.
	 */
	public void setSecurityPolicy(){
		System.setProperty("java.security.policy","file:./security.policy");
	}
	
	/**
	 * Loads the server connections strings.
	 */
	private void loadServerConnectionString(){
		serverConnectionString = new HashMap<String, String>();
		serverConnectionString.put("SPVM", "localhost:2020/SPVM");
		serverConnectionString.put("SPL", "localhost:2021/SPL");
		serverConnectionString.put("SPB", "localhost:2022/SPB");
	}
	
	/**
	 * Returns the server connection string based on the station name.
	 * @return The server connection string.
	 */
	public String getServerConnectionString(){
		return serverConnectionString.get(stationName);
	}
}